package com.tjetc.rabbitmq;

import com.tjetc.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 *
 * 消费者
 *
 * @author gaoyongxiang
 * @version v1.0
 * @since 2025-11-04
 */
@Service
public class Receiver {

    // 基础队列
    @RabbitListener(queues = RabbitMQConfig.BASIC_QUEUE)
    public void receive(Object msg){
        System.out.println(msg);
    }

    // fanout
    @RabbitListener(queues = RabbitMQConfig.FANOUT_QUEUE1)
    public void receiveFanoutQueue1(Object msg) {
        System.out.println("fanout_queue1" + msg);
    }

    @RabbitListener(queues = RabbitMQConfig.FANOUT_QUEUE2)
    public void receiveFanoutQueue2(Object msg) {
        System.out.println("fanout_queue2" + msg);
    }

    // direct
    @RabbitListener(queues = RabbitMQConfig.DIRECT_QUEUE1)
    public void receiveDirectQueue1(Object msg) {
        System.out.println(msg);
    }


    @RabbitListener(queues = RabbitMQConfig.DIRECT_QUEUE2)
    public void receiveDirectQueue2(Object msg) {
        System.out.println(msg);
    }


    // topic
    @RabbitListener(queues = RabbitMQConfig.TOPIC_QUEUE1)
    public void receiveTopicQueue1(Object msg) {
        System.out.println(msg);
    }


    @RabbitListener(queues = RabbitMQConfig.TOPIC_QUEUE2)
    public void receiveTopicQueue2(Object msg) {
        System.out.println(msg);
    }
}
